<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <p>事件绑定</p>
    <!-- 1. 不传参数，调用函数可以不写括号 -->
    <button v-on:click="say">say hi</button>
    <hr>
    <!-- 2.传参,自定义参数 -->
    <button @click="sayWord('你好', 123, name)">说话</button>
    <hr>
    <!-- 3.传参，预定义参数，事件对象固定名字 $event，显式传递 -->
    <button @click="getEvent($event)">获取事件对象</button>
    <input type="text" @keyup="getEvent($event)">
    <hr>
    <!-- 4.既有自定义参数，又有$event -->
    <button @click="show('你好', $event)">说话</button>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        name: 'Tom',
        val1: ''
      },
      methods: {
        say(e) {
          // 隐式传递
          console.log(e);
          alert('Hi ~');
        },
        sayWord(key1, key2, key3) {
          alert(key1)
          alert(key2)
          alert(key3)
        },
        getEvent(e) {
          console.log(e);
        },
        show(arg1, arg2) {
          // argment 参数
          console.log(arg1);
          console.log(arg2);
        }
      },
    })
  </script>
</body>
</html>